//
//  introduceTableViewCell.m
//  YiFei
//
//  Created by yangyan on 16/8/31.
//  Copyright © 2016年 yous. All rights reserved.
//

#import "introduceTableViewCell.h"

@implementation introduceTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addView];
    }
    return self;
}

-(void)addView{
    _viewback=[[UIView alloc] init];
    [_viewback sizeToFit];
    _viewback.backgroundColor=[UIColor whiteColor];
    _viewback.layer.masksToBounds=YES;
    _viewback.layer.cornerRadius=5.0;

    _viewback.frame=CGRectMake(10, 0, WIDTH-20, 9*30);
    [self.contentView addSubview:_viewback];

    _lable=[[UILabel alloc] init];
    [_lable sizeToFit];
    _lable.font=[UIFont systemFontOfSize:13.0];
    _lable.textColor=[UIColor lightGrayColor];
    _lable.numberOfLines=0;
    [_viewback addSubview:_lable];
}

+(CGFloat)getCellHeight:(NSString *)text{
    CGSize size=CGSizeMake(WIDTH-88-20, 100);
    CGRect rect=[text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0]} context:nil];
    return rect.size.height+10;
}

-(void)setShopD:(shopData *)shopD{
    [self addView];
   _lHeight= [introduceTableViewCell getCellHeight:shopD.shopTerms];
    _lable.frame=CGRectMake(10,5,WIDTH-40,_lHeight);
    _lable.text=shopD.shopTerms;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
